Overview

This document has code embedded throughout. In the next section we will create a visualization using the already loaded dataset cryptodata:

datatable(cryptodata, rownames = FALSE, 
          options(list(lengthMenu = c(4, 5, 6))))

Price Chart

Interactive Chart

Python Code Example

import pandas as pd
# Create the Python object from R
df = r.cryptodata
# Show the new Python dataframe
df
##         pair symbol  ask_1_price       date_time_utc
## 0     ETHUSD    ETH      547.455 2020-12-09 02:00:01
## 1     ETHUSD    ETH      550.456 2020-12-09 01:00:01
## 2     ETHUSD    ETH      554.995 2020-12-09 00:00:01
## 3     ETHUSD    ETH      554.403 2020-12-08 23:00:01
## 4     ETHUSD    ETH      566.320 2020-12-08 22:00:01
## ...      ...    ...          ...                 ...
## 2020  ETHUSD    ETH      347.606 2020-09-09 14:00:38
## 2021  ETHUSD    ETH      346.886 2020-09-09 13:00:39
## 2022  ETHUSD    ETH      347.578 2020-09-09 12:00:39
## 2023  ETHUSD    ETH      346.624 2020-09-09 11:00:38
## 2024  ETHUSD    ETH      357.844                 NaT
## 
## [2025 rows x 4 columns]

One more Python example

Press on w on your keyboard to make the presentation wider. Press f to fullscreen.

import numpy as np
# Create a new field based on the ask_1_price value:
df['price_percentile'] = np.where(df['ask_1_price'] > np.percentile(df['ask_1_price'], 50),
                            'upper 50th percentile of prices', 
                            'lower 50th percentile of prices')
# Show modified dataframe:
df[['symbol', 'ask_1_price', 'price_percentile']]
##      symbol  ask_1_price                 price_percentile
## 0       ETH      547.455  upper 50th percentile of prices
## 1       ETH      550.456  upper 50th percentile of prices
## 2       ETH      554.995  upper 50th percentile of prices
## 3       ETH      554.403  upper 50th percentile of prices
## 4       ETH      566.320  upper 50th percentile of prices
## ...     ...          ...                              ...
## 2020    ETH      347.606  lower 50th percentile of prices
## 2021    ETH      346.886  lower 50th percentile of prices
## 2022    ETH      347.578  lower 50th percentile of prices
## 2023    ETH      346.624  lower 50th percentile of prices
## 2024    ETH      357.844  lower 50th percentile of prices
## 
## [2025 rows x 3 columns]

Back to Gallery